package queue

type BlockQueue[T any] struct {
	elements chan T
}

func Create[T any](capacity int) *BlockQueue[T] {
	blockQueue := &BlockQueue[T]{
		elements: make(chan T, capacity),
	}
	return blockQueue
}

func (queue *BlockQueue[T]) Put(data T) bool {
	queue.elements <- data
	return true
}

func (queue *BlockQueue[T]) Take() T {
	data := <-queue.elements
	return data
}
